<?php
//recipe.php

if(!isset($authorizedPage)) require('error.php');



class Recipie{
	private $recipieID;
	private $recipieUserID;
	private $recipieTags = array();
	private $recipieDescription;
	private $recipieName;
	private $recipieSteps = array();
	private $recipieIngredients = array();
	private $recipieMaterials = array();
	private $recipieImgMain;
	private $recipieImgStep = array();
	private $recipieImgIngr = array();
	private $recipieImgMate = array();
	private $recipieTime 	= array();
	private $recipieTotalTime = 0;
	
	public function __construct($rid){
		$this->recipieID = $rid;
	}
	
	public function fillVariables(){
		$results = mysql_fetch_array(mysql_query("SELECT * FROM recipie WHERE id = '$this->recipieID'"));

		if(strlen($results[0]) < 1) return false;
		
		$this->recipieUserID 		= $results[1];
		$this->recipieTags 			= NULL; //explode($results[2],"%NEXT%");
		$this->recipieDescription 	= $results[3]; 
		$this->recipieName 			= $results[4];
		$this->recipieSteps 		= explode("%NEXT%",$results[5]);
		$this->recipieIngredients 	= explode("%NEXT%",$results[6]);
		$this->recipieMaterials		= explode("%NEXT%",$results[7]);
		$this->recipieImgMain		= $results[8];
		$this->recipieImgStep		= explode("%NEXT%",$results[9]);
		$this->recipieImgIngr		= explode("%NEXT%",$results[10]);
		$this->recipieImgMate		= explode("%NEXT%",$results[11]);
		$this->recipieTotalTime 	= $results[12];
		$this->recipieTime			= explode("%NEXT%",$results[13]);
				
		return true;
	}
	
	public function getRID(){
		return $this->recipieID;
	}
	
	public function getRUserID(){
		return $this->recipieUserID;
	}
	
	public function getRFacebookName(){
		$pageContent = file_get_contents('http://graph.facebook.com/' . $this->getRUserID());
		$parsedJson  = json_decode($pageContent);
		return $parsedJson->name;
	}
	
	public function getRFacebookProfile(){
		return '<img src="http://graph.facebook.com/'.$this->getRUserID().'/picture?type=normal&height=104" alt="'.$this->getRFacebookName().' Profile Picture" />';
	}
	
	public function getRTags(){
		$this->recipieTags;
	}
	
	public function getRDescription(){
		return $this->recipieDescription;
	}
	
	public function getRName(){
		return $this->recipieName;
	}
	
	public function getRSteps(){
		return $this->recipieSteps;
	}
	
	public function getRTimes(){
		return $this->recipieTime;
	}
	
	public function getRTotalTimes(){
		return $this->recipieTotalTime;
	}
	
	public function getRIngredients(){
		return $this->recipieIngredients;
	}
	
	public function getRMaterials(){
		return $this->recipieMaterials;
	}
	
	public function getRImgMain(){
		return $this->recipieImgMain;
	}
	
	public function getRImgStep(){
		return $this->recipieImgStep;
	}
	
	public function getRImgIngr(){
		return $this->recipieImgIngr;
	}
	
	public function getRImgMate(){
		return $this->recipieImgMate;
	}
}


?>